<?php

namespace App\Http\Controllers\Agency;

use App\Http\Controllers\Controller;
use App\Services\SlipService;
use Illuminate\Http\Request;
use hg\apidoc\annotation as Apidoc;

/**
 * 小纸条管理
 * @Apidoc\Group("market")
 */

class SlipController extends Controller
{
    /**
     * @Apidoc\Title ("客户详情-更新小纸条状态")
     * @Apidoc\Url("/agency/slipStatusUpdate")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("id",type="int",require=true,desc="纸条列表id")
     * @Apidoc\Param("status",type="string",require=true,desc="wait待审核；pass通过；refuse未通过")
     * @Apidoc\Returned("true",type="bool",desc="保存状态")
     *
     */
    public function slipStatusUpdate(Request $request ,SlipService $slipService)
    {
        $params = $request->input();
        $result = $slipService->updateSlipStatus($params);
        if($result)
            return $this->responseSuccess($result);
        else
            return $this->responseError(400);
    }

    /**
     * @Apidoc\Title ("小纸条-基础配置")
     * @Apidoc\Url("/agency/getSlipBase")
     * @Apidoc\Method("GET")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Returned("isopen",type="string",desc="是否启用；Y启用；N关闭")
     * @Apidoc\Returned("isallow",type="string",desc="是否启用；Y启用；N关闭")
     * @Apidoc\Returned("notvipnums",type="string",desc="非VIP用户每天最多发送条数")
     * @Apidoc\Returned("vipnums",type="string",desc="vip用户每天可额外发送条数")
     * @Apidoc\Returned("onreplynums",type="string",desc="未回复之前最多发送条数")
     *
     */
    public function getSlipBase(Request $request ,SlipService $slipService)
    {
        $params = $request->input();
        $params['aid'] = $this->getAid();
        $result = $slipService->getSlipBase($params);
        return $this->responseSuccess($result);
    }

    /**
     * @Apidoc\Title ("小纸条-更新基础配置")
     * @Apidoc\Url("/agency/slipBaseUpdate")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("id",type="int",require=true,desc="纸条列表id")
     * @Apidoc\Param("isopen",type="string",desc="是否启用；Y启用；N关闭")
     * @Apidoc\Param("isallow",type="string",desc="是否启用；Y启用；N关闭")
     * @Apidoc\Param("notvipnums",type="string",desc="非VIP用户每天最多发送条数")
     * @Apidoc\Param("vipnums",type="string",desc="vip用户每天可额外发送条数")
     * @Apidoc\Param("onreplynums",type="string",desc="未回复之前最多发送条数")
     * @Apidoc\Returned("true",type="bool",desc="保存状态")
     *
     */
    public function slipBaseUpdate(Request $request ,SlipService $slipService)
    {
        $params = $request->input();
        $result = $slipService->slipBaseUpdate($params);
        if($result)
            return $this->responseSuccess($result);
        else
            return $this->responseError(400);
    }

    /**
     * @Apidoc\Title ("小纸条-内容配置")
     * @Apidoc\Url("/agency/getSlipTemplate")
     * @Apidoc\Method("GET")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Returned("content",type="string",desc="模板内容")
     * @Apidoc\Returned("status",type="string",desc="是否启用；Y启用；N关闭")
     * @Apidoc\Returned("order",type="string",desc="排序字段")
     * @Apidoc\Returned("vipnums",type="string",desc="vip用户每天可额外发送条数")
     * @Apidoc\Returned("onreplynums",type="string",desc="未回复之前最多发送条数")
     *
     */
    public function getSlipTemplate(Request $request ,SlipService $slipService)
    {
        $params = $request->input();
        $params['aid'] = $this->getAid();
        $result = $slipService->getSlipTemplate($params);
        return $this->responseSuccess($result);
    }

    /**
     * @Apidoc\Title ("小纸条-添加内容配置")
     * @Apidoc\Url("/agency/slipTemplateSave")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("id",type="int",require=false,desc="id为空添加；不为空编辑")
     * @Apidoc\Param("content",type="string",require=true,desc="模板内容")
     * @Apidoc\Param("reply",type="object",desc="用户基本信息",children={
     *   @Apidoc\Param("content",type="string",require=true,desc="模板内容"),
     *   @Apidoc\Param("content",type="string",require=true,desc="模板内容"),
     * }),
     * @Apidoc\Returned("true",type="bool",desc="保存状态")
     *
     */
    public function slipTemplateSave(Request $request ,SlipService $slipService)
    {
        $params = $request->input();
        $params['aid'] = $this->getAid();
        $result = $slipService->slipTemplateSave($params);
        if($result)
            return $this->responseSuccess($result);
        else
            return $this->responseError(400);
    }

    /**
     * @Apidoc\Title ("小纸条-删除纸条模板")
     * @Apidoc\Url("/agency/slipTemplateDel")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("id",type="int",require=true,desc="纸条模板id")
     * @Apidoc\Returned("true",type="bool",desc="保存状态")
     *
     */
    public function slipTemplateDel(Request $request ,SlipService $slipService)
    {
        $params = $request->input();
        $result = $slipService->slipTemplateDel($params);
        if($result)
            return $this->responseSuccess($result);
        else
            return $this->responseError(400);
    }

    /**
     * @Apidoc\Title ("小纸条-更新纸条模板状态")
     * @Apidoc\Url("/agency/slipTemplateStatusUpdate")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("id",type="int",require=true,desc="纸条模板列表id")
     * @Apidoc\Param("status",type="string",require=true,desc="Y启用N停用")
     * @Apidoc\Returned("true",type="bool",desc="保存状态")
     *
     */
    public function slipTemplateStatusUpdate(Request $request ,SlipService $slipService)
    {
        $params = $request->input();
        $result = $slipService->slipTemplateStatusUpdate($params);
        if($result)
            return $this->responseSuccess($result);
        else
            return $this->responseError(400);
    }

    /**
     * @Apidoc\Title ("小纸条-更新纸条模板排序")
     * @Apidoc\Url("/agency/slipTemplateOrderUpdate")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("orders",type="object",require=true,desc="排序数组",children={
     * @Apidoc\Param("id",type="int",require=true,desc="id")
     * })
     * @Apidoc\Param("status",type="string",require=true,desc="Y启用N停用")
     * @Apidoc\Returned("true",type="bool",desc="保存状态")
     *
     */
    public function slipTemplateOrderUpdate(Request $request ,SlipService $slipService)
    {
        $params = $request->input();
        $result = $slipService->slipTemplateOrderUpdate($params);
        if($result)
            return $this->responseSuccess($result);
        else
            return $this->responseError(400);
    }


    /**
     * @Apidoc\Title ("小纸条-消息记录")
     * @Apidoc\Url("/agency/getSlipList")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("type",type="int",desc="1发送者id；2接收者id；3发送者昵称；4接收者昵称；5发送者手机；6接收者手机")
     * @Apidoc\Param("keyword",type="string",desc="关键字")
     *
     */
    public function getSlipList(Request $request ,SlipService $slipService)
    {
        $params = $request->input();
        $params['aid'] = $this->getAid();
        $result = $slipService->getSlipList($params);
        return $this->responseSuccess($result);
    }

}
